// menu.ts

/** 菜单基础信息 */
export interface MenuItem {
  id: number;
  createTime: string;
  path: string;
  parentId: number;
  menuName: string;
  icon: string;
  nickName: string;
  children?: MenuItem[];
}

/** 权限菜单响应结构 */
export interface AccessMenuResult {
  success: boolean;
  code: number;
  message: string;
  data: {
    data: MenuItem[]; // 注意：这里嵌套了两层 data
  };
}


// auth-api.ts 或单独建 menu-api.ts

import { baseRequestClient, requestClient } from '#/api/request';

/**
 * 获取用户权限菜单
 */
export async function getAccessMenusApi() {
  return requestClient.get<AccessMenuResult>('/routing/treeAll');
}

/**
 *   修改路由信息
 */
export async function routerUpdateApi(data:MenuItem) {
  return requestClient.post<AccessMenuResult>('/routing/update',data);
}
/**
 *   添加路由信息
 */
export async function routerSaveApi(data:MenuItem) {
  return requestClient.post<AccessMenuResult>('/routing/save',data);
}

/**
 * 删除节点
 */
export async function routerDeleteApi(data:Array<String>) {
  return requestClient.post<AccessMenuResult>('/routing/delete',data);
}

/**
 * 获取节点
 */
export async function routerFindAllApi() {
  return requestClient.get<AccessMenuResult>('/routing/findAll');
}
